# Copyright 2009 Autodesk, Inc.  All rights reserved.
# Use of this software is subject to the terms of the Autodesk license agreement 
# provided at the time of installation or download, or which otherwise accompanies
# this software in either electronic or hard copy form.

# Script description:
# Set the translation of a newly created cube and show how to find a model by its name
#
# Topic: FBScene, FBComponent, FBFindModelByName
#

from pyfbsdk import FBModelCube, FBSystem, FBComponent, FBModelCube_TypeInfo, FBFindModelByName, FBVector3d

lobj = FBModelCube('Cube')
lobj.Show = True

# Going through all the items in the scene
for lComp in FBSystem().Scene.Components:

            # in this particular case we are looking for anything with the type of FBModelCube
            if lComp != None and lComp.Is(FBModelCube_TypeInfo()):

                        # Get to the handle to the model
                        lcube = FBFindModelByName(lComp.Name)

                        # Use the screen name to set the translation vector
                        ltran = lcube.PropertyList.Find ( 'Translation (Lcl)' ).Data = FBVector3d( -10, 5, 20 )
                        if not ltran:
                            print "Can't find value"

# Clean-up
del(lobj, FBModelCube, FBSystem, FBComponent, FBFindModelByName, FBModelCube_TypeInfo, lComp, FBVector3d)